AC_SUBST(CALENDAR_SERVER_CFLAGS)
AC_SUBST(CALENDAR_SERVER_LIBS)
+AC_ARG_WITH(systemd,
+ AS_HELP_STRING([--with-systemd],
+ [Add systemd support]),
+ [with_systemd=$withval], [with_systemd=auto])
+
+PKG_CHECK_MODULES(SYSTEMD,
+ [libsystemd-login libsystemd-daemon],
+ [have_systemd=yes], [have_systemd=no])
+
+if test "x$with_systemd" = "xauto" ; then
+ if test x$have_systemd = xno ; then
+ use_systemd=no
+ else
+ use_systemd=yes
+ fi
+else
+ use_systemd=$with_systemd
+fi
+
+if test "x$use_systemd" = "xyes"; then
+ if test "x$have_systemd" = "xno"; then
+ AC_MSG_ERROR([Systemd support explicitly required, but systemd not found])
+ fi
+
+ AC_DEFINE(WITH_SYSTEMD, 1, [systemd support])
+fi
+
MUTTER_GIR_DIR=`$PKG_CONFIG --variable=girdir libmutter`
MUTTER_TYPELIB_DIR=`$PKG_CONFIG --variable=typelibdir libmutter`
AC_SUBST(MUTTER_GIR_DIR)
const Lang = imports.lang;
const Mainloop = imports.mainloop;
+const GLib = imports.gi.GLib;
const Gio = imports.gi.Gio;
const Params = imports.misc.params;
+const Shell = imports.gi.Shell;
const Main = imports.ui.main;
const ShellMountOperation = imports.ui.shellMountOperation;
const ScreenSaver = imports.misc.screenSaver;
return self;
}
+function haveSystemd() {
+ return GLib.access("/sys/fs/cgroup/systemd", 0) >= 0;
+}
+
const AutomountManager = new Lang.Class({
Name: 'AutomountManager',
this._settings = new Gio.Settings({ schema: SETTINGS_SCHEMA });
this._volumeQueue = [];
- this.ckListener = new ConsoleKitManager();
+ if (!haveSystemd())
+ this.ckListener = new ConsoleKitManager();
this._ssProxy = new ScreenSaver.ScreenSaverProxy();
this._ssProxy.connectSignal('ActiveChanged',
return false;
},
+ _sessionActive: function() {
+ // Return whether the current session is active, using the
+ // right mechanism: either systemd if available or ConsoleKit
+ // as fallback.
+
+ if (haveSystemd())
+ return Shell.session_is_active_for_systemd();
+
+ return this.ckListener.sessionActive;
+ },
+
_onDriveConnected: function() {
// if we're not in the current ConsoleKit session,
// or screensaver is active, don't play sounds
- if (!this.ckListener.sessionActive)
- return;
+ if (!this._sessionActive())
+ return;
if (this._ssProxy.screenSaverActive)
return;
_onDriveDisconnected: function() {
// if we're not in the current ConsoleKit session,
// or screensaver is active, don't play sounds
- if (!this.ckListener.sessionActive)
- return;
+ if (!this._sessionActive())
+ return;
if (this._ssProxy.screenSaverActive)
return;
_onDriveEjectButton: function(monitor, drive) {
// TODO: this code path is not tested, as the GVfs volume monitor
// doesn't emit this signal just yet.
- if (!this.ckListener.sessionActive)
+ if (!this._sessionActive())
return;
// we force stop/eject in this case, so we don't have to pass a
if (params.checkSession) {
// if we're not in the current ConsoleKit session,
// don't attempt automount
- if (!this.ckListener.sessionActive)
+ if (!this._sessionActive())
return;
if (this._ssProxy.screenSaverActive) {
#include <libxml/tree.h>
#include <libxml/xmlmemory.h>
+#ifdef WITH_SYSTEMD
+#include <systemd/sd-daemon.h>
+#include <systemd/sd-login.h>
+#endif
+
/* Some code in this file adapted under the GPLv2+ from:
*
* GNOME panel utils: gnome-panel/gnome-panel/panel-util.c
name,
&gvalue);
}
+
+/**
+ * shell_session_is_active_for_systemd:
+ *
+ * Checks whether the session we are running in is currently active,
+ * i.e. in the foreground and ready for user input.
+ *
+ * Returns: TRUE if session is active
+ */
+gboolean
+shell_session_is_active_for_systemd (void)
+{
+ /* If this isn't systemd, let's assume the session is active. */
+
+#ifdef WITH_SYSTEMD
+ if (sd_booted () <= 0)
+ return TRUE;
+
+ return sd_session_is_active (NULL) != 0;
+#else
+ return TRUE;
+#endif
+}